package com.example.springkotlin.contactInfo

import com.example.springkotlin.contactInfo.domain.ContactInfo
import com.example.springkotlin.contactInfo.domain.ContactInfoService
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.*


@RestController
@RequestMapping("/contact")
class ContactInfoController {

    @Autowired
    private lateinit var contactInfoService: ContactInfoService

    @PostMapping("/handle")
    fun handleData(@RequestBody contactInfoList: List<ContactInfo>?){
        val contactinfo: ContactInfo = ContactInfo("11","11","11","1")
        val contactinfo2: ContactInfo = ContactInfo("11@qq.com","11","11","2")
        val contactinfo3: ContactInfo = ContactInfo("11@163.com","11","11","3")
        val contactinfo4: ContactInfo = ContactInfo("11@sinosoft.com","11","11","4")
        val contactinfo5: ContactInfo = ContactInfo("112@qq.com","11","11","5")
        val list :ArrayList<ContactInfo> = arrayListOf(contactinfo,contactinfo2,contactinfo3,contactinfo4,contactinfo5)
        contactInfoService.handleEmailData(list).forEach(::println)
    }
}